package olga.gorbatiuk.perdep.logger.record.comparator;

import java.util.Comparator;

import olga.gorbatiuk.perdep.logger.record.Record;

public class ByDateAndImportanceComparator implements Comparator<Record> {

    @Override
    public int compare(Record record1, Record record2) {
        int result = record1.getImportance().getIntValue()
                - (record2.getImportance().getIntValue());
        if (result != 0) {
            return result;
        } else {
            result = new ByDateComparator().compare(record1, record2);
            if (result != 0) {
                return result;
            }
        }
        return 0;
    }
}
